Skip to content

Conversation

gmarull
Copy link
Member

@gmarull gmarull commented Sep 16, 2025

Add flash (QSPI NOR) driver for SF32LB

@gmarull gmarull requested a review from cameled September 16, 2025 13:21
@github-actions github-actions bot added manifest manifest-hal_sifli DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Sep 16, 2025
@gmarull gmarull force-pushed the sf32lb52x-flash branch 3 times, most recently from ce5be5e to 7335cff Compare September 17, 2025 19:05
@zephyrproject-rtos zephyrproject-rtos deleted a comment from github-actions bot Oct 1, 2025
@gmarull gmarull removed the DNM (manifest) This PR should not be merged (controlled by action-manifest) label Oct 1, 2025
@gmarull gmarull force-pushed the sf32lb52x-flash branch 3 times, most recently from 5218a60 to 003a034 Compare October 1, 2025 12:10
@gmarull gmarull marked this pull request as ready for review October 1, 2025 12:10
@gmarull
Copy link
Member Author

gmarull commented Oct 1, 2025

Questions for @rabbitsaviola

  • Please review the driver in general
  • DMA code is not placed in RAM, but it's called from flash_sf32lb_mpi_qspi_nor_write, is it okay?
  • Clarify in general what is strictly needed to be placed in RAM
  • Clarify why using write chunk lengths > FIFO size does not work (L324); use, e.g., teslabs@43a7ae6 to check

@gmarull gmarull added the DNM This PR should not be merged (Do Not Merge) label Oct 1, 2025
@rabbitsaviola
Copy link

  • DMA code is not placed in RAM, but it's called from flash_sf32lb_mpi_qspi_nor_write, is it okay?

it's ok that DMA code is not placed in RAM as sequence command mode used.

  • Clarify why using write chunk lengths > FIFO size does not work (L324); use, e.g., teslabs@43a7ae6 to check

write doesn't work when chunk_len > FIFO size is because RBSIZE is set to 3 by L535. If RBSIZE is 0, chunk_len=128byte works well.

@gmarull
Copy link
Member Author

gmarull commented Oct 14, 2025

last push: moved flash nor parameters to module-level variable, same as in spi_nor.c (and fixed write block size).

@gmarull gmarull requested a review from fabiobaltieri October 14, 2025 15:28
@gmarull gmarull force-pushed the sf32lb52x-flash branch 2 times, most recently from 178403c to 8274aca Compare October 14, 2025 18:59

description: Generic NOR flash on QSPI bus

compatible: "jedec,qspi-nor"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this new binding needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see commit description, we cannot use jedec,spi-nor because it's tied to SPI buses, but, in Zephyr, QSPI controllers live in a limbo.

Add compatible for SiFli SF32LB MPI operating as QSPI NOR controller.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
Compatible should be set at board level, depending on how MPI IP is used
(e.g. NOR, NAND, PSRAM).

Signed-off-by: Gerard Marull-Paretas <[email protected]>
No longer used.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
Ideally we should be able to just use jedec,spi-nor (to keep Linux
compatibility), but, QSPI controllers live in a limbo in Zephyr. Adding
this binding won't make things worse than they are.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
Command was missing.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
So we can obtain a register address (as hex) given its name.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
Take it from the chosen flash node parent (MPI controller) 'nor'
register, which contains the memory mapped address for the NOR flash.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
Initial driver for the SF32LB MPI accessing QSPI NOR flash devices.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
So that flash driver can be used (MPI2 works in QSPI mode).

Signed-off-by: Gerard Marull-Paretas <[email protected]>
Allow obtaining SFDP parameters using SF32LB driver.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
Copy link

@gmarull
Copy link
Member Author

gmarull commented Oct 15, 2025

last pushes:

  • qspi_nor_read_fifo pushed to RAM (was causing issues when e.g. reading JEDEC ID, FYI @rabbitsaviola)
  • Fixed incorrect flash size (128mbit)

Copy link
Contributor

@cameled cameled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, test pass on my board.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants